There are 4 main logical operators :
They operate on the individual bits of a stored number.
NOT
| NOT | 0 | 1 |
| 1 | 0 |
Example
NOT F0 = NOT 11110000 = 00001111 = 0F
AND
a AND b = 1 if (a=1) AND (b=1)
The Truth Table is as follows :
| AND | 0 | 1 |
| 0 | 0 | 0 |
| 1 | 0 | 1 |
Example
6B AND 56
| 6B | = | 01101011 |
| 56 | = | 01010110 |
| 6B AND 56 | = | 01000010 |
| = | 42 |
OR
a OR b = 1 if (a=1) OR (b=1) or both
The Truth Table is as follows :
| OR | 0 | 1 |
| 0 | 0 | 1 |
| 1 | 1 | 1 |
Example
6B OR 56
| 6B | = | 01101011 |
| 56 | = | 01010110 |
| 6B OR 56 | = | 01111111 |
| = | 7F |
XOR
a XOR b = 1 if (a=1) or (b=1) but not both.
The Truth Table is as follows :
| AND | 0 | 1 |
| 0 | 0 | 0 |
| 1 | 0 | 1 |
Example
6B XOR 56
| 6B | = | 01101011 |
| 56 | = | 01010110 |
| 6B XOR 56 | = | 00111101 |
| = | 3D |
Exercises
(All answers are in Hexadecimal)